package weekMatch.two_104;

import com.sun.org.apache.xpath.internal.operations.Or;

import java.util.Arrays;

public class LeeCode_04 {
    public static void main(String[] args) {
        System.out.println(sumOfPower(new int[]{1, 2, 4}));
        System.out.println(sumOfPower(new int[]{1, 1, 1}));
    }
    private static int sumOfPower(int[] nums) {
        Arrays.sort(nums);
        long pre = 0, ans = 0, mod = 100_000_0007L;
        for (int num : nums) {
            long res = (pre + num) % mod * num % mod * num % mod;
            ans = (ans + res) % mod;
            pre = (pre * 2 % mod + num) % mod;
        }
        return (int) (ans % mod);
    }
}
